<!DOCTYPE html>
<html lang="en">
<head>

    <title>发布文章</title>
    <th:block th:include="admin/include :: common-css" />
    <script src="../back/js/html5shiv.js"></script>
    <script src="../back/js/respond.min.js"></script>
	<link href="../back/plugins/tagsinput/jquery.tagsinput.css" rel="stylesheet"/>
    <link href="../back/plugins/select2.dist.css/select2-bootstrap.css" rel="stylesheet"/>
    <link href="../back/plugins/toggles/toggles.css" rel="stylesheet"/>
    <link href="../back/plugins/mditor/css/mditor.min.css" rel="stylesheet"/>
    <link href="../back/plugins/dropzone/4.3.0/min/dropzone.min.css" rel="stylesheet">
<style>
    #tags_tagsinput {
        background-color: #fafafa;
        border: 1px solid #eeeeee;
    }

    #tags_addTag input {
        width: 100%;
    }

    #tags_addTag {
        margin-top: -5px;
    }

    .mditor .editor{
        font-size: 14px;
        font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
    }
    .mditor .backdrop, .mditor .textarea, .mditor .viewer{
        font-size: 14px;
    }
    .markdown-body{
        font-size: 14px;
    }
    .note-toolbar {
        text-align: center;
    }

    .note-editor.note-frame {
        border: none;
    }

    .note-editor .note-toolbar {
        background-color: #f5f5f5;
        padding-bottom: 10px;
    }

    .note-toolbar .note-btn-group {
        margin: 0;
    }

    .note-toolbar .note-btn {
        border: none;
    }

    #articleForm #dropzone {
        min-height: 200px;
        background-color: #dbdde0;
        line-height:200px;
        margin-bottom: 10px;
    }
    #articleForm .dropzone {
        border: 1px dashed #8662c6;
        border-radius: 5px;
        background: white;
    }
    #articleForm .dropzone .dz-message {
        font-weight: 400;
    }
    #articleForm .dropzone .dz-message .note {
        font-size: 0.8em;
        font-weight: 200;
        display: block;
        margin-top: 1.4rem;
    }
</style>
</head>

<body class="fixed-left">
<div id="wrapper">
    <th:block th:include="admin/include :: header-menu(2)" />

    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">
                            
                            
                                发布文章
                            
                        </h4>
                    </div>
                    <div class="col-md-12">
                        <form id="articleForm">
                            <input type="hidden" name="id" th:value="${article.id}" id="id"/>
                            <input type="hidden" name="allowComment" value="true" id="allow_comment"/>
                            <input type="hidden" name="content"  id="content-editor"/>
                            <div class="form-group col-md-6" style="padding: 0 10px 0 0;">
                                <input type="text" class="form-control" placeholder="请输入文章标题（必须）" th:value="${article.title}" name="title" required="required" aria-required="true"/>
                            </div>
                            <div class="form-group col-md-6" style="padding: 0 10px 0 0;">
                                <input name="tags" id="tags" type="text" class="form-control" th:value="${article.tags}" placeholder="请输入文章标签" />
                            </div>
                            <div class="clearfix"></div>
                            <div id="md-container" class="form-group">
                                <textarea id="md-editor" th:text="${article.content}"></textarea>
                            </div>

                            <div class="clearfix"></div>

                            <div class="text-right">
                                <a class="btn btn-default waves-effect waves-light" href="/admin/list">返回列表</a>
                                <button type="button" id="saveBtn" class="btn btn-primary waves-effect waves-light" >
                                    保存文章
                                </button>
                            </div>
                        </form>

                    </div>
                </div>

            </div>
        </div>
    </div>
</div>

    <th:block th:include="admin/include :: footer" />

    <th:block th:include="admin/include :: common-js" />

<script src="../back/plugins/tagsinput/jquery.tagsinput.min.js"></script>
<script src="../back/plugins/jquery-multi-select/jquery.quicksearch.js"></script>

<script src="../back/plugins/mditor/js/mditor.min.js"></script>
<script src="../back/plugins/multi-select/0.9.12/js/jquery.multi-select.min.js"></script>
<script src="../back/plugins/select2/3.4.8/select2.min.js"></script>
<!--<script src="//cdn.bootcss.com/jquery-toggles/2.0.4/toggles.min.js"></script>-->
<script src="../back/plugins/dropzone/4.3.0/min/dropzone.min.js"></script>
<script src="../back/plugins/to-markdown/3.1.0/to-markdown.min.js"></script>

<script src="../back/js/article.js"></script>
<script>
    $("#saveBtn").click(function(){
        $("#content-editor").val(mditor.value)
        $.ajax({
            type: 'post',
            url: '/article/saveOrUpdate',
            data: $("#articleForm").serialize(),
            async: true,
            dataType: 'json',
            success: function (result) {
                if(result.code == 0){
                    alert("文章发布成功");
                    window.location.href="/admin/list";
                }else{
                    alert(result.msg)
                }
                console.log(result)
            }
        });
    });

</script>
</body>
</html>